package routers

import (
	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
	"post-master/handlers"
)

func Init() *gin.Engine {

	r := gin.Default()

	//设置跨域
	r.Use(cors.Default())
	//设置静态文件的目录
	r.Static("static", "./static")

	//设置路由
	r.POST("/post/add", handlers.Add)  //帖子添加
	r.GET("/post/list", handlers.List) //帖子列表
	r.GET("/post/del", handlers.Del)   //帖子删除

	return r

}
